package cn.edu.tjnu.action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;

import cn.edu.tjnu.orm.ChargeBean;
import cn.edu.tjnu.orm.UsersBean;
import cn.edu.tjnu.service.IChargeInfoService;

public class ChargeInfoAction {
	private static final long serialVersionUID = 1L;
	private ChargeBean chargeB;
	private IChargeInfoService ChargeInfoS;
	Map<String, Object> session = ActionContext.getContext().getSession();

	/*
	 * 用户电费查询
	 * 
	 * @return
	 */
	public  String queryAllChargeInfo(){
		String str_result = "failed";
		// 调用service层进行用户信息查询处理
		List<ChargeBean> lstCharge = ChargeInfoS.queryAllChargeInfo(chargeB);
		// 将需要显示的新增的所有的用户信息，通过session传递到前台页面
		// 将查询结果集进行session缓存处理
		if (lstCharge != null && lstCharge.size() > 0){
		session.put("lstCharge", lstCharge);
		str_result="success";
		}
		return str_result; 
	}
	public  String queryShowChargeInfo(){
		String str_result = "failed";
		// 调用service层进行用户信息查询处理
		List<ChargeBean> showCharge = ChargeInfoS.queryShowChargeInfo(chargeB);
		// 将需要显示的新增的所有的用户信息，通过session传递到前台页面
		// 将查询结果集进行session缓存处理
		if (showCharge != null && showCharge.size() > 0){
		session.put("showCharge", showCharge);
		str_result="success";
		}
		return str_result; 
	}
	public String savaChargeInfo(){
		String str_re="failed";
		int i = ChargeInfoS.saveChargeInfo(chargeB);
		if(i>0){
			str_re="success";
		}			
		return str_re;
	}
	public String saveConsumeChargeInfo(){
		String str_re="failed";
		int i = ChargeInfoS.saveConsumeChargeInfo(chargeB);
		if(i>0){
			str_re="success";
		}			
		return str_re;
	}

	public ChargeBean getChargeB() {
		return chargeB;
	}

	public void setChargeB(ChargeBean chargeB) {
		this.chargeB = chargeB;
	}

	public IChargeInfoService getChargeInfoS() {
		return ChargeInfoS;
	}

	public void setChargeInfoS(IChargeInfoService chargeInfoS) {
		ChargeInfoS = chargeInfoS;
	}

	public Map<String, Object> getSession() {
		return session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}



	

}
